# -*- ecoding: utf-8 -*-
# @Author: Wick
# @Time: 2024-02-24 19:31

class Person:  # 类名
    def __init__(self, name, age, height):  # 属性在init中
        self.name = name
        self.age = age
        self.height = height

    def run(self):
        print(f'{self.name}在跑步')

    def eat(self):
        print("eat")

    def __str__(self):
        """
        重写str，打印对象得到的值，是这个方法返回的值
        :return:
        """
        return self.name  # 这个方法是str所以返回的值要是一个str才行

    def __del__(self):
        print("对象将要被销毁")


class Dog:
    def __init__(self, name, color):
        self.name = name
        self.color = color

    def bark(self):
        print("bark")

    def wag_tail(self):
        print("wag_tail")



xiao_ming = Person('小明', 18, 180)
print(xiao_ming.name)
xiao_ming.run()

xiao_hong = Person("小红", 18, 187)
print(id(xiao_ming), id(xiao_hong))

#is可以判断两个对象是否指向同一个空间
print(xiao_hong is xiao_ming)

#不正规的对象添加属性
xiao_ming.weight = 75
print(xiao_ming.weight)
# print(xiao_hong.weight)

print(xiao_ming)
print(xiao_hong)